package cn.itcast.nems.discounts.dao.mapper;

import cn.itcast.nems.discounts.dao.dataobject.EmsDiscountApplyScopeDO;
import cn.itcast.nems.discounts.dao.dataobject.EmsDiscountsDO;
import cn.itcast.nems.discounts.dao.entiry.EmsDiscounts;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.lang.NonNull;

import java.util.Collection;
import java.util.List;
import java.util.Set;

@Mapper
@InterceptorIgnore(tenantLine = "true")
public interface EmsDiscountsMapper extends BaseMapper<EmsDiscounts> {

    /**
     * 根据 校区ID、学科、班级类型ID、开班时间和报道时间查询优惠项
     * @param discountsDO 查询参数
     * @return 优惠项
     */
    List<EmsDiscountsDO> getDiscountsByCondition(@Param("discountsDO") EmsDiscountsDO discountsDO) ;

    /**
     * 产线关联优惠项
     * @param discountsDO 查询参数
     * @return 优惠项
     */
    List<EmsDiscountsDO> findByParentIdByClazzId(@Param("discountsDO") EmsDiscountsDO discountsDO) ;

    /**
     * 查询关联的子优惠
     * @param parentId 父节点ID
     * @return 优惠列表
     */
    List<EmsDiscountsDO> findDiscountsByParentId(@Param("parentId") Integer parentId) ;

    /**
     * 报名页面-优惠列表查询
     * @param page 分页查询
     * @param discountsDO 请求参数
     * @return 分页结果
     */
    IPage<EmsDiscountsDO> findEnrolPageList(Page<EmsDiscountsDO> page, @Param("discountsDO") EmsDiscountsDO discountsDO) ;

    /**
     * 分页查询
     * @param page 分页参数
     * @param discountsDO 查询条件
     * @return List<EmsDiscountsDO>
     */
    IPage<EmsDiscountsDO> findPageList(Page<EmsDiscountsDO> page, @Param("discountsDO") EmsDiscountsDO discountsDO);


    List<EmsDiscountsDO> findByIdList(@Param("idList") Collection<Integer> idList) ;

    /**
     * 查询优惠券作用范围
     *
     * @param discountIds 优惠券ID集合
     * @return java.util.List<cn.itcast.nems.discounts.dao.dataobject.EmsDiscountApplyScopeDO>
     * @author 高昌露
     * @since 2023/12/7 10:45
     */
    List<EmsDiscountApplyScopeDO> queryDiscountApplyScopeByDiscountIds(@Param("discountIds") @NonNull Set<Integer> discountIds);
}
